<?php
namespace Home\Controller;
use Think\Controller;
class GroupController extends Controller {
    public function index(){
      $this->display();
    }

 public function grouplist(){
  $groupModel=M('groups');
  $this->groups=$groupModel->field('gid,groupname,logo')->select();
  $this->display();
 }

public function groupDetail($id){
	$groupModel=M('Groups');
	$this->groups=$groupModel->select($id);
  $practiceModel=M('Members');
	$this->members=$practiceModel->join('Users on Members.stunum=users.stunum')->where('members.gid='.$id)->select();
  $this->display();

}
public function addGroupUser(){
   $groupModel=M('Members');
   $groupModel->create();
   $data['gid']=$_GET['id'];
   $data['stunum']=session('user.stunum');
   if ($groupModel->where($data)->select()) {
     $this->error('已申请');
   }
   else
   {
  if ($groupModel->data($data)->add()) {
    $this->success('申请成功');
   }
   else
    $this->error('申请失败');
}
}
}
?>
